package com.client.job.utils;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
public class DataResult {
	private Integer code;
	private String message;
	private boolean success;
	private Object data;   
	private Integer requestType;
	
	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	

	public static DataResult buildSuccess() {
		return new DataResult(200, "返回正确", true, null);
	}

	public static DataResult buildSuccess(Object t) {
		return new DataResult(200, "返回正确", true, t);
	}

	public static <T> DataResult buildSuccess(String msg, T t) {
		return new DataResult(200, msg, true, t);
	}

	public static DataResult buildSuccess(Integer code, String msg, Object t) {
		return new DataResult(code, msg, true, t);
	}

	public static DataResult buildFail() {
		return new DataResult(201, "返回失败", false, null);
	}

	public static DataResult buildFail(String msg) {
		return new DataResult(201, msg, false, null);
	}
	
	

	public static DataResult buildFail(Integer code, String msg) {
		return new DataResult(code, msg, false, null);
	}

	public static DataResult buildFail(String msg, Object data) {
		return new DataResult(201, msg, false, data);
	}

	public static DataResult buildFail(Integer code, String msg, Object obj) {
		return new DataResult(code, msg, false, obj);
	}
	
	public static DataResult  buildByInter(Integer  curdRes) {
		if(curdRes > 0) {
			return buildSuccess();
		}
		 return buildFail();
	}

	public Integer getRequestType() {
		return requestType;
	}

	public void setRequestType(Integer requestType) {
		this.requestType = requestType;
	}

	public DataResult(Integer code, String message, boolean success, Object data) {
		super();
		this.code = code;
		this.message = message;
		this.success = success;
		this.data = data;
	}
	
	public  DataResult buildRequestType(Integer type) {
		this.requestType = type;
		return this;
	}

}
